package com.xzy.mybatis.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.transaction.event.TransactionPhase;
import org.springframework.transaction.event.TransactionalEventListener;

/**
 * @author xzy.xiao
 * @date 2023/11/6  19:30
 */
@Slf4j
@Component
public class CustomerEventListener {

    @EventListener
    public void handleCustomerEvent1(CustomerEvent customerEvent) {
        log.info("EventListener --> {}", customerEvent.getData());

    }

    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    public void handleCustomerEvent2(CustomerEvent customerEvent) {
        log.info("TransactionalEventListener --> {}", customerEvent.getData());
    }
}
